<template>
  <div id="app">
    <h1 align="center">投诉内容</h1><br>
    <el-input
      type="textarea"
      :rows="8"
      placeholder="请输入内容"
      v-model="content"
    class="complaint">
    </el-input><br>
    <el-button type="primary" @click="Submit">
      提交
    </el-button>
  </div>
</template>

<script>
import axios from 'axios'
import router from '../../router'

export default {
  name: 'Complaint',
  data () {
    return {
      id: this.$route.params.id,
      content: '',
      type_id: 0
    }
  },
  methods: {
    Submit: function () {
      if (this.content === '') {
        alert('请输入内容')
      } else {
        axios.post(`user/task/report`, {
          task_id: this.id,
          content: this.content
        }).then(res => {
          if (res.data.status === 100) {
            alert(res.data.data.msg)
            return this.$router.push({
              path: '/MyFinishedTask'
            })
          } else {
            alert(res.data.data.msg)
            return this.$router.push({
              path: '/MyFinishedTask'
            })
          }
        }).catch(err => {
          alert(err)
          router.replace('/login')
        })
      }
    }
  }
}
</script>

<style scoped>
.complaint{
  text-align: center;
  height: 350px;
  margin: 30px auto;
  width: 600px;
}
</style>
